#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

char line[200];
string message;
bool start = true;
typedef struct TWord {
	string val;
	int pos;
} TWord;

typedef struct TWords {
	string val;
	vector<int> pos;
	bool isTrue;
} TWords;

const int MAXWORD = 11000;
const int MAXCHAR = 10100;
TWord dict[MAXWORD];
int dictLen;
bool single[MAXWORD];
int mark[MAXCHAR];
bool trueWord[MAXWORD];
TWords mergedDict[MAXWORD];
int mergedDictLen;

bool operator < (const TWord& x, const TWord& y) {
	if (x.val == y.val) {
		if (x.pos == y.pos)
			return x.val.length() < y.val.length();
		return x.pos < y.pos;
	}
	return x.val < y.val;
}

bool operator == (const TWord& x, const TWord& y) {
	return x.val == y.val;
}

bool operator < (const TWords& x, const TWords& y) {
	if (!x.isTrue) return false;
	if (!y.isTrue) return true;
	if ((x.pos[0]<=y.pos[0] && y.pos[0] <= x.pos[0] + x.val.length())
		|| (y.pos[0]<=x.pos[0] && x.pos[0] <= y.pos[0] + y.val.length())) {
			return (x.pos[0] + x.val.length()) < (y.pos[0] + y.val.length());
	}
	return x.pos[0] < y.pos[0];
}

void solve(string message) {
	int length = message.length();
// 	cout << "'" << message << "'" << endl;
	dictLen = 0;
	for (int i=0; i<length-1; ++i) {
 		if (i>0)
 			if (message[i]==message[i-1]) continue;
		for (int j=i+1; j<=min(int(i+2+250), length); ++j) {
			if (i==0) {
				if (j == length) continue; 
				bool notWord = false;
				for (int k=0; k<j; ++k)
					if (message[j] == message[k]) {
						notWord = true;
						break;
					}
				if (notWord) continue;
			}
			else {
				char begin = message[i-1];
				char end;
				if (j == length) end = '*';
				else end = message[j];
				if (end != '*' && begin != end) continue;
			}
			if (j-i<2) {
				if (i == 0) continue;
				else break;
			}
			dict[dictLen].pos = i;
			dict[dictLen].val = message.substr(i, j-i);
			sort(dict[dictLen].val.begin(), dict[dictLen].val.end());
			++dictLen;
			if (i!=0) break;
		}
	}

// 	cout << "dict: " << endl;
// 	for (int i=0; i<dictLen; ++i)
// 		cout << "\t" << dict[i].val << " " << dict[i].pos << endl;


	sort(dict, dict+dictLen);
	memset(single, 0, MAXWORD);
	for (int i=0; i<dictLen-1; ++i) {
		if (dict[i] == dict[i+1]) {
			++i;
			while(i<dictLen-1 && dict[i]==dict[i+1]) ++i;
		}
		else
			single[i] = true;
	}

	if (dictLen>0) single[dictLen-1] = true;
	if (dictLen>1)
		if (dict[dictLen-1]==dict[dictLen-2])
			single[dictLen-1] = false;
	int idx = 0;
	for (int i=0; i<dictLen; ++i)
		if (!single[i])
			dict[idx++] = dict[i];
	dictLen = idx;
	
// 	cout << "dict: " << endl;
// 	for (int i=0; i<dictLen; ++i)
// 		cout << "\t" << dict[i].val << " " << dict[i].pos << endl;

	if (dictLen == 0) {
		cout << "*" << endl;
		return;
	}

	idx = 0;
	mergedDict[0].val = dict[0].val;
	mergedDict[0].pos.clear();
	mergedDict[0].pos.push_back(dict[0].pos);
	mergedDict[0].isTrue = false;
	for (int i=1; i<dictLen; ++i) {
		if (dict[i] == dict[i-1]) {
			mergedDict[idx].pos.push_back(dict[i].pos);
		}
		else {
			++idx;
			mergedDict[idx].val = dict[i].val;
			mergedDict[idx].pos.clear();
			mergedDict[idx].pos.push_back(dict[i].pos);
			mergedDict[idx].isTrue = false;
		}
	}
	mergedDictLen = idx+1;

	for (int i=0; i<MAXCHAR; ++i) mark[i] = -1;
	for (int i=0; i<mergedDictLen; ++i) {
		int wordLen = mergedDict[i].val.length();
		for (int j=0; j<mergedDict[i].pos.size(); ++j) {
			int startPos, endPos;
			startPos = mergedDict[i].pos[j];
			endPos = startPos+wordLen;
			for (int k=startPos; k<endPos; ++k)
				if (mark[k] != -1) {
					mergedDict[mark[k]].isTrue = true;
					mergedDict[i].isTrue = true;
				}
				else
					mark[k] = i;
		}
	}

	sort(mergedDict, mergedDict+mergedDictLen);

	for (int i=0; i<mergedDictLen; ++i) {
		if (mergedDict[i].isTrue)
			cout << message.substr(mergedDict[i].pos[0], mergedDict[i].val.length()) << endl;
		else
			break;
	}
	cout << "*" << endl;
}

int main(void)
{
	while (true) {
		if (start == true)
			message = "";
		memset(line, 0, 200);
		cin.getline(line, 200);

		int len = strlen(line);
		if (len == 1 && line[0] == '#') break;
		if (line[len-1] == '-') start = false;
		else start = true;
		int idx = 0;
		for (int i=0; i<len; ++i)
			if ('a'<=line[i] && line[i]<='z')
				line[idx++] = line[i];
		message += string(line, idx);
		if (start) {
			solve(message);
		}
	}
	return 0;
}